home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / updates / update15.zoo / lib / diffs < prev    next >
Encoding:
Text File  |  1992-02-04  |  46.8 KB  |  1,874 lines

  1. *** 1.63    1992/01/14 18:46:50
  2. --- Changelo    1992/02/04 17:15:53
  3. ***************
  4. *** 2620,2622 ****
  5. --- 2620,2786 ----
  6.       the next's. make adjustments to unlink_handler.
  7.   
  8.   ---------------------------- Patchlevel 74 ---------------------------
  9. + scanf.c:: Michael Ritzert
  10. +     - incorrect return value if fewer data items than specified
  11. +     could be read: the supplied _scanf always returns -1 in this case.
  12. +     Instead, it should return EOF if the error occured before 
  13. +     the first data item to be read and the number of items
  14. +         read with success later on.
  15. +     - the %c format passes the character following the one to be read.
  16. + fscanf.c:: ++jrb
  17. +     #define fungetc to ungetc for pre Ansi sunOS 4.0.*
  18. + ctype.[ch]:: andreas
  19. +     allow negative characters (also handles 0xff correctly)
  20. + fopen/fdopen:: andreas
  21. +     set errno to EMFILE if there are no more FILE slots free
  22. +      (gawk uses it)
  23. + fputc:: andreas
  24. +     don't return EOF if c == (signed char)0xff
  25. + malloc.c:: andreas
  26. +     split memory didn't work
  27. +     the memory allocation routines if using the split memory
  28. +     model, sbrk can return values which are out of order, due to switching
  29. +     from system heap to own heap.
  30. + lstat:: andreas
  31. +     unx2dos already stored the link flags in __link_flags; no
  32. +      need to call unx2dos twice
  33. + system:: andreas
  34. +     command line argument can be arbitrary long, hope no longer
  35. +     than BUFSIZ
  36. + unx2dos:: andreas
  37. +     the link contents can be a full pathname in symbolic links
  38. + write.c:: andreas
  39. +     handle chars with high bit set correctly
  40. + fcntl.h:: andreas
  41. +     GEMDOS returns file handles <= 80 (for TOS 1.4, don't know
  42. +     about newer TOS's)
  43. + main.c:: andreas
  44. +     indices into __open_stat were mixed with file handles.
  45. + system.c:: frank
  46. +     skip over quotes.
  47. + pwd.h, getpw.c:: frank, ++jrb
  48. +     adjust types for uid and gid. they should be uid_t and gid_t 
  49. +     respectively.
  50. + pipe.c:: ++jrb
  51. +     cleanup: get rid of -Wall warnings.
  52. + localtim.c:: ++jrb
  53. +     if the time given is weird, return the epoch. this is a questionable
  54. + fix: we used to return NULL, but that seems to cause problems, as things
  55. + that use the pointer returned by localtime() never seem to check for
  56. + the possibility of a NULL. my handy ANSI reference is mum on what to
  57. + do when the  time given is weird. this was causing zoo to blow up in
  58. + zoosrc/nixtime.i when trying to archive files with weird timestamps (some
  59. + people seem to have a weird kbd processor that time warps!).
  60. + ostruct.h:: Bill Shroka
  61. +     NEW file. it contains most of the popular OS (non Aes/Vdi) structures
  62. +     Thanks bill: this is a good beginning to this file, it more or
  63. +     less corresponds to franks Documentation/varcard.tex. We can add
  64. +     on more stuff as needed.
  65. + osbind.h:: Bill Shroka
  66. +     use <ostruct.h>
  67. + pipe.c:: ++jrb
  68. +     All fprintf() in here needed to be conditional upon DEBUG. Thanks
  69. + to michal for finding this. his code was unexpectedly pulling in all
  70. + kinds of stuff due to external references tp fprintf() here.
  71. + pipe.c, close.c:: ++jrb
  72. +     take out direct call to pipeclose() from close to avoid pulling
  73. + in all the pipe stuff into programs that dont use pipes. instead
  74. + go thru a pointer that is initially nulled, and if the program calles
  75. + pipe() is patched in with the address of pipeclose(). this way only the code
  76. + that actually uses pipes will link in the pipe code.
  77. + crt0.c:: ++jrb
  78. +     cleanup.
  79. + float.h: mjr
  80. +     cleanup values to better reflect reality.
  81. + ***** NOTE ***** ***** NOTE ***** ***** NOTE ***** ***** NOTE *****
  82. + _addsubd.s _addsubs.s _divdf3.s _divsf3.s _extends.s _fixdfsi.s _fxunsd.s
  83. + _floatsi.s _muldf3.s _mulsf3.s _normdf.s _normsf.s _truncdf.s modf.s:: mjr
  84. +     NOTE: these .S files replaced with corresponding .CPP files.
  85. + mincl:: ++jrb
  86. +     adjust targets for above
  87. + math-68881.h:: ++mjr
  88. +     removed any error checking code (use the library versions if
  89. +     error checking is required)
  90. + frexp:: ++mjr
  91. +     y = frexp(0,ip) now corectly returns 0 both in y and *ip
  92. +     sfp004 - version written but not tested due to lack of hardware
  93. +     my sfp004 board died, so only a "plausibility test" could be made.
  94. +     most probable sources of bugs: 
  95. +     the fscale instruction has been inserted to the old function body 
  96. +     after the dead of the board.
  97. +     The test if the 1st arg is 0, too.
  98. + doprnt.c:: ++mjr
  99. +     NAN and INFINITY conditions are caught by analysing only the most
  100. +     significant long word (uniqe).
  101. +     this also serves as a workaround to the conversion bug of 
  102. +     gcc-as 
  103. +     (DBL_MAX is converted to 0x7ff00000 0x00000002
  104. +             instead of   0x7fefffff 0xfffffffe
  105. +     ) which sometimes causes doprnt to crash.
  106. + _fixdfsi.cpp:
  107. + _fixunsdfsi.cpp:
  108. +     optional error checking added. 
  109. +     All three situations (no fpu, sfp004, TT) supported.
  110. + _normsf.cpp:
  111. + _divdf3.cpp:
  112. + _divsf3.cpp:
  113. +     returns signed infinity in case of an exception.
  114. +     if option ERROR_CHECK is enabled:
  115. +     _errno is set to ERANGE.
  116. +     The EDOM situation 0/0 is not tested explicitly.
  117. +     All three situations (no fpu, sfp004, TT) supported.
  118. + _normdf.cpp:
  119. +     if option ERROR_CHECK is enabled:
  120. +     _errno is set to ERANGE.
  121. +     message is printed.
  122. +     value of ERANGE corrected to 62 (was 34 = EPATH)
  123. + ldexp.cpp:
  124. +     value of ERANGE corrected to 62 (was 34 = EPATH)
  125. +     optional ERROR_CHECK inserted.
  126. +     underflow is no longer considered an error condition to
  127. +     stay consistent with pml.
  128. +     if ERROR_CHECK is enabled, a message is printed on overflow.    
  129. + _addsubd.cpp:
  130. + _addsubs.cpp:
  131. + _muldf3.cpp:
  132. + _mulsf3.cpp:    ++mjr:
  133. +     sfp004 code and software floating point code merged into one file.
  134. + ---------------------------- Patchlevel 75 ---------------------------
  135. *** 1.50    1991/12/26 15:53:59
  136. --- PatchLev.h    1992/02/04 17:15:54
  137. ***************
  138. *** 1,5 ****
  139.   
  140. ! #define    PatchLevel "74"
  141.   
  142.   /*
  143.    *
  144. --- 1,5 ----
  145.   
  146. ! #define    PatchLevel "75"
  147.   
  148.   /*
  149.    *
  150. *** 1.19    1991/12/26 15:53:59
  151. --- atof.c    1992/02/04 17:16:01
  152. ***************
  153. *** 27,34 ****
  154.    *    the old naive coding is at the end bracketed by ifdef __OLD__.
  155.    *    modeled after peter housels posting on comp.os.minix.
  156.    *    thanks peter!
  157. !  *        ++jrb
  158.    */
  159.   #if !(defined(unix) || defined(minix))
  160.   #include <stddef.h>
  161.   #include <stdlib.h>
  162. --- 27,38 ----
  163.    *    the old naive coding is at the end bracketed by ifdef __OLD__.
  164.    *    modeled after peter housels posting on comp.os.minix.
  165.    *    thanks peter!
  166. !  *
  167. !  *    mjr: 68881 version added
  168.    */
  169. + #if !defined (__M68881__) && !defined (sfp004)
  170.   #if !(defined(unix) || defined(minix))
  171.   #include <stddef.h>
  172.   #include <stdlib.h>
  173. ***************
  174. *** 240,246 ****
  175.       register short e     = 0;
  176.       double       zero = 0.0;
  177.       const char        *tmp;
  178.       assert ((s != NULL));
  179.   
  180.       if(endptr != NULL) *endptr = (char *)s;
  181. --- 244,250 ----
  182.       register short e     = 0;
  183.       double       zero = 0.0;
  184.       const char        *tmp;
  185. !  
  186.       assert ((s != NULL));
  187.   
  188.       if(endptr != NULL) *endptr = (char *)s;
  189. ***************
  190. *** 281,287 ****
  191.       {
  192.       if(*++s != '\0') /* skip e|E|d|D */
  193.       {  /* ! ([s]xxx[.[yyy]]e)  */
  194. !         tmp = s;
  195.           while(Isspace(*s)) s++; /* Ansi allows spaces after e */
  196.           if(*s != '\0')
  197.           { /*  ! ([s]xxx[.[yyy]]e[space])  */
  198. --- 285,291 ----
  199.       {
  200.       if(*++s != '\0') /* skip e|E|d|D */
  201.       {  /* ! ([s]xxx[.[yyy]]e)  */
  202. !          tmp = s;
  203.           while(Isspace(*s)) s++; /* Ansi allows spaces after e */
  204.           if(*s != '\0')
  205.           { /*  ! ([s]xxx[.[yyy]]e[space])  */
  206. ***************
  207. *** 324,453 ****
  208.       return strtod(s, (char **)NULL);
  209.   }
  210.   
  211. - #ifdef TEST
  212. - #ifdef __MSHORT__
  213. - #error "please run this test in 32 bit int mode"
  214. - #endif
  215. - #define NTEST 10000L
  216. - #ifdef unix
  217. - #ifdef __MSHORT__
  218. - #define    RAND_MAX    (0x7FFF)    /* maximum value from rand() */
  219. - #else
  220. - #define    RAND_MAX    (0x7FFFFFFFL)    /* maximum value from rand() */
  221. - #endif
  222. - #endif
  223. - main()
  224. - {
  225. -     
  226. -     double expected, result, e, max_abs_err;
  227. -     char buf[128];
  228. -     register long i, errs;
  229. -     register int s;
  230. - #ifdef __STDC__
  231. -     double atof(const char *);
  232. -     int rand(void);
  233. - #else
  234. -     extern double atof();
  235. -     extern int rand();
  236. - #endif
  237. - #if 0
  238. -     expected = atof("3.14159265358979e23");
  239. -     expected = atof("3.141");
  240. -     expected = atof(".31415"); 
  241. -     printf("%f\n\n", expected);
  242. -     expected = atof("3.1415"); 
  243. -     printf("%f\n\n", expected);
  244. -     expected = atof("31.415"); 
  245. -     printf("%f\n\n", expected);
  246. -     expected = atof("314.15"); 
  247. -     printf("%f\n\n", expected);
  248. -     expected = atof(".31415"); 
  249. -     printf("%f\n\n", expected);
  250. -     expected = atof(".031415"); 
  251. -     printf("%f\n\n", expected);
  252. -     expected = atof(".0031415"); 
  253. -     printf("%f\n\n", expected);
  254. -     expected = atof(".00031415"); 
  255. -     printf("%f\n\n", expected);
  256. -     expected = atof(".000031415"); 
  257. -     printf("%f\n\n", expected);
  258. -     expected = atof("-3.1415e-9"); 
  259. -     printf("%20.15e\n\n", expected);
  260. -     expected = atof("+3.1415e+009"); 
  261. -     printf("%20.15e\n\n", expected);
  262. - #endif
  263. -     expected = atof("+3.123456789123456789"); 
  264. -     printf("%30.25e\n\n", expected);
  265. -     expected = atof(".000003123456789123456789"); 
  266. -     printf("%30.25e\n\n", expected);
  267. -     expected = atof("3.1234567891234567890000000000"); 
  268. -     printf("%30.25e\n\n", expected);
  269. -     expected = atof("9.22337999999999999999999999999999999999999999"); 
  270. -     printf("%47.45e\n\n", expected);
  271. -     expected = atof("1.0000000000000000000"); 
  272. -     printf("%25.19e\n\n", expected);
  273. -     expected = atof("1.00000000000000000000"); 
  274. -     printf("%26.20e\n\n", expected);
  275. -     expected = atof("1.000000000000000000000"); 
  276. -     printf("%27.21e\n\n", expected);
  277. -     expected = atof("1.000000000000000000000000"); 
  278. -     printf("%30.24e\n\n", expected);
  279. -  
  280. - #if 0
  281. -     expected = atof("1.7e+308");
  282. -     if(errno != 0)
  283. -     {
  284. -     printf("%d\n", errno);
  285. -     }
  286. -     else    printf("1.7e308 OK %g\n", expected);
  287. -     expected = atof("1.797693e308");    /* anything gt looses */
  288. -     if(errno != 0)
  289. -     {
  290. -     printf("%d\n", errno);
  291. -     }
  292. -     else    printf("Max OK %g\n", expected);
  293. -     expected = atof("2.225073858507201E-307");
  294. -     if(errno != 0)
  295. -     {
  296. -     printf("%d\n", errno, expected);
  297. -     }
  298. -     else    printf("Min OK %g\n", expected);
  299. - #endif
  300. -     
  301. -     max_abs_err = 0.0;
  302. -     for(errs = 0, i = 0; i < NTEST; i++)
  303. -     {
  304. -     expected = (double)(s = rand()) / (double)rand();
  305. -     if(s > (RAND_MAX >> 1)) expected = -expected;
  306. -     sprintf(buf, "%.14e", expected);
  307. -     result = atof(buf);
  308. -     e = (expected == 0.0) ? result : (result - expected)/expected;
  309. -     if(e < 0) e = (-e);
  310. -     if(e > 1.0e-6) 
  311. -     {
  312. -         errs++; printf("%.14e %s %.14e (%.14e)\n", expected, buf, result, e);
  313. -     }
  314. -     if (e > max_abs_err) max_abs_err = e;
  315. -     }
  316. -     printf("%ld Error(s), Max abs err %.14e\n", errs, max_abs_err);
  317. - }
  318. - #endif /* TEST */
  319.   
  320.   /* old naive coding */
  321.   #ifdef __OLD__
  322. --- 328,333 ----
  323. ***************
  324. *** 567,569 ****
  325. --- 447,847 ----
  326.       return r;
  327.   }
  328.   #endif /* __OLD__ */
  329. + #else    __M68881__ || sfp004
  330. + #if 0
  331. + #ifndef    sfp004
  332. + # define _M68881    /* use the predefined inline functions                */
  333. + #endif    sfp004
  334. + #endif 0
  335. + /* M.R's kludgy atof --- 881 version.                        */
  336. + /*     uses long integer accumulators and extended precision to put them    */
  337. + /*    together in the fpu. The conversion long to extended is done completely    */
  338. + /*    on the 881.                                */
  339. + /*    using extended precision in _float_ avoids rounding errors.        */
  340. + /* 12.7.1989, 11.10.90, 28.1.91, 24.11.91                    */
  341. + /* On overflow, only +-infinity is returned (the 68881's default).        */
  342. + /* 24.11.91: return +-MAXDOUBLE instead of +- INFINITY or NAN            */
  343. + /*           set errno to ERANGE/EDOM                        */
  344. + # include <ctype.h>
  345. + # include <stdio.h>
  346. + # include <float.h>
  347. + # include <math.h>
  348. + # include <errno.h>
  349. + # include "flonum.h"
  350. + double atof( const char * );
  351. + double strtod( const char *, const char ** );
  352. + double _Float_( long, long, long, long );
  353. + # define    true 1
  354. + # define false 0
  355. + # define CharIsDigit ( isdigit(*Text) )
  356. + # define Digit ((*Text-'0'))
  357. + #if 0
  358. + static unsigned long
  359. +     __notanumber[2] = { 0x7fffffffL, 0xffffffffL }; /* ieee NAN */
  360. + # define NAN  (*((double *)&__notanumber[0]))
  361. + # endif 0
  362. + # define ten_mul(X)    ((((X) << 2) + (X)) << 1)
  363. + double strtod( const char * Save, const char ** Endptr )
  364. + {
  365. +   register int Count; int Negative = false, ExpNegative = false;
  366. +   double Value;
  367. +   union double_di * l_Value;
  368. +   register long Exponent, Exp_Temp;
  369. +   register long Value_1, Value_2;
  370. +   register char c;
  371. +   register char * Text;
  372. +   register char * Places;
  373. +   char Buffer[15];
  374. +   l_Value = (union double_di *) &Value;
  375. +   Text = Save;
  376. +   Places = Buffer;
  377. +   /* skip over leading whitespace */
  378. +   while (isspace(*Text)) Text++;
  379. +   if (*Text == '-') {
  380. +     Negative = true;
  381. +     Text++;
  382. +   } else
  383. +   if (*Text == '+') {
  384. +     Negative = false;
  385. +     Text++;
  386. +   } else
  387. +   if( *Text == 0 ) {
  388. +     if( Endptr != NULL ) *Endptr = Text;
  389. +     return 0.0;
  390. +   }
  391. +   /* Process the 'f'-part                             */
  392. +   /* ignore any digit beyond the 15th                         */
  393. +   /* BUG: may overflow if more than 10 digits precede the '.'            */
  394. +   /* to cure use to accumulators as is being done for the digits after        */
  395. +   /* the '.'.                                    */
  396. +   Exp_Temp = 0;            /* needed later on for the exponential part    */
  397. +   Value_1 = 0; Value_2 = 0; Count = 0; Exponent = 0;
  398. +   while( CharIsDigit ) {    /* process digits before '.'            */
  399. +     if( Count < 15 ) {
  400. +       Count++;
  401. +       *Places++ = Digit;
  402. +     }
  403. +     Text++;
  404. +   }
  405. +   if ( *Text == '.') {
  406. +     Text++;
  407. +     while( CharIsDigit ) {    /* process digits after '.'            */
  408. +       if( Count < 15 )    {
  409. +         Count++;
  410. +             *Places++ = Digit;
  411. +         Exponent--;
  412. +       }
  413. +       Text++;
  414. +     }
  415. +   }
  416. +   Places = Buffer;
  417. +   /* Now, Places points to a vector of <= 15 digits                */
  418. +   /* text points to the position immediately after the end of the mantissa    */
  419. +   /* Value_2 will contain the equiv. of the 8 least significant digits, while    */
  420. +   /* Value_1 will contain the equiv. of the 7 most significant digits (if any)    */
  421. +   /* and therefore has to be multiplied by 10^8                    */
  422. +   /* no overflow possible in the temporary buffers                */
  423. +   while( Count > 8 )    {
  424. +       Value_1 = ten_mul( Value_1 );      Value_1 += *Places++;
  425. +       Count--;
  426. +   }
  427. +   while( Count > 0 )    {
  428. +       Value_2 = ten_mul( Value_2 );      Value_2 += *Places++;
  429. +       Count--;
  430. +   }
  431. +   /* 'e'-Part */
  432. +   if ( *Text == 'e' || *Text == 'E' || *Text == 'd' || *Text == 'D' ) {
  433. +     char * Tail = Text;
  434. +     Text++;
  435. +     /* skip over whitespace since ANSI allows space after e|E|d|D        */
  436. +     while (isspace(*Text)) Text++;
  437. +     if ( * Text == '-' ) {
  438. +         ExpNegative = true;
  439. +         Text++;
  440. +     } else
  441. +     if( * Text == '+' ) {
  442. +         ExpNegative = false;
  443. +         Text++;
  444. +     }
  445. +     if( !CharIsDigit ) {
  446. +         *Endptr = Tail;    /* take the 'e|E|d|D' as part of the characters    */
  447. +         goto Ende;        /* following the number            */
  448. +     } else {
  449. +     /* Exponents may have at most 3 digits, everything beyond this will be    */
  450. +     /* silently ignored                            */
  451. +         Count = 0;
  452. +         while( CharIsDigit && (Count < 3) ) {
  453. +             Exp_Temp = ten_mul( Exp_Temp ); Exp_Temp += Digit;
  454. +               Count++;
  455. +             Text++;
  456. +         }
  457. +         if( ExpNegative ) Exp_Temp = -Exp_Temp;
  458. +         Exponent += Exp_Temp;
  459. +      }
  460. +   }
  461. +   Value = _Float_( Value_1, Exponent+8L, Value_2, Exponent );
  462. +   if( Endptr != NULL ) *Endptr = Text;
  463. +   if( (l_Value -> i[0]) >= 0x7ff00000U )    { /* INFINITY or NAN        */
  464. +     fprintf(stderr," strtod: OVERFLOW error\n");
  465. +     errno = ERANGE;
  466. +     Value = DBL_MAX;
  467. +   }
  468. + Ende:    
  469. +   if( Negative ) {
  470. +     Value = -Value;
  471. +   }
  472. +   return( Value );
  473. + # if 0
  474. + Error:
  475. +   fputs("\njunk number \"",stderr); fputs(Save,stderr); 
  476. +   fputs("\" --- returning NAN\n",stderr);
  477. +   errno = ERANGE;
  478. +   if( Endptr != NULL ) *Endptr = Text;
  479. +   return(NAN);    /* == Not A Number (NAN) */
  480. + # endif
  481. + }
  482. + double atof( const char * Text )
  483. + {
  484. +     return(strtod(Text,(char **)NULL));
  485. + }
  486. + /*
  487. +  * double _Float_( long Value_1, long Exponent_1, long Value_2, long Exponent_2 )
  488. +  *
  489. +  * merges the accumulators Value_1, Value_2 and the Exponent to a double
  490. +  * precision float
  491. +  * called by strtod()
  492. +  *
  493. +  * does all floating point computations with extended precision on the fpu
  494. +  */
  495. + #endif __M68881__ || sfp004
  496. + #ifdef __M68881__
  497. + asm(
  498. + ".even
  499. + .text
  500. +     .globl __Float_
  501. + __Float_:
  502. +     ftentoxl    a7@(8),fp1        | load Exponent_1
  503. +     ftentoxl    a7@(16),fp2        | load Exponent_2
  504. +     fmull        a7@(12),fp2        | fmull Value_2 -> fp2
  505. +     fmull        a7@(4),fp1        | fmull Value_1 -> fp1
  506. +     faddx        fp2,fp1
  507. +     fmoved        fp1,a7@-        | fmoved fp1 -> d0/d1
  508. +     moveml        a7@+,d0-d1
  509. +      rts
  510. + ");
  511. + #endif    __M68881
  512. + #ifdef    sfp004
  513. + asm("| mjr, 30.1.1991
  514. + |
  515. + | base =    0xfffa50
  516. + |      the fpu addresses are taken relativ to 'base':
  517. + |
  518. + | a0: fpu base address
  519. + |
  520. + | waiting loop ...
  521. + |
  522. + | wait:
  523. + | ww:    cmpiw    #0x8900,a0@(resp)
  524. + |     beq    ww
  525. + | is coded directly by
  526. + |    .long    0x0c688900, 0xfff067f8 (a0)
  527. + | and
  528. + | www:    tst.w    a0@(resp)
  529. + |    bmi.b    www
  530. + | is coded by
  531. + |    .word    0x4a68,0xfff0,0x6bfa        | test
  532. + |
  533. + comm =     -6
  534. + resp =    -16
  535. + zahl =      0
  536. +     .globl __Float_
  537. + .even
  538. + .text
  539. + __Float_:
  540. +     lea    0xfffa50,a0            | fpu address
  541. +     movew    #0x4092,a0@(comm)        | ftentoxl -> fp1
  542. +     .long    0x0c688900, 0xfff067f8
  543. +     movel    a7@(8),a0@            | load Exponent_1
  544. +     movew    #0x4112,a0@(comm)        | ftentoxl -> fp2
  545. +     .long    0x0c688900, 0xfff067f8
  546. +     movel    a7@(16),a0@            | load Exponent_2
  547. +     movew    #0x4123,a0@(comm)        | fmull Value_2 -> fp2
  548. +     .long    0x0c688900, 0xfff067f8
  549. +     movel    a7@(12),a0@            | load Value_2
  550. +     movew    #0x40a3,a0@(comm)        | fmull Value_1 -> fp1
  551. +     .long    0x0c688900, 0xfff067f8
  552. +     movel    a7@(4),a0@            | load Value_1
  553. +     movew    #0x08a2,a0@(comm)        | faddx fp2 -> fp1
  554. +     .word    0x4a68,0xfff0,0x6bfa        | test
  555. +     movew    #0x7480,a0@(comm)        | fmoved fp1 -> d0/d1
  556. +     .long    0x0c688900, 0xfff067f8
  557. +     movel    a0@,d0
  558. +     movel    a0@,d1
  559. +      rts
  560. + ");
  561. + #endif    sfp004
  562. + #ifdef TEST
  563. + #if 0
  564. + #ifdef __MSHORT__
  565. + #error "please run this test in 32 bit int mode"
  566. + #endif
  567. + #endif
  568. + #define NTEST 10000L
  569. + #ifdef __MSHORT__
  570. + # define    RAND_MAX    (0x7FFF)    /* maximum value from rand() */
  571. + #else
  572. + # define    RAND_MAX    (0x7FFFFFFFL)    /* maximum value from rand() */
  573. + #endif
  574. + main()
  575. + {
  576. +     
  577. +     double expected, result, e, max_abs_err;
  578. +     char buf[128];
  579. +     register long i, errs;
  580. +     register long s;
  581. + #ifdef __STDC__
  582. +     double atof(const char *);
  583. +     int rand(void);
  584. + #else
  585. +     extern double atof();
  586. +     extern int rand();
  587. + #endif
  588. + #if 0
  589. +     expected = atof("3.14159265358979e23");
  590. +     expected = atof("3.141");
  591. +     expected = atof(".31415"); 
  592. +     printf("%f\n\n", expected);
  593. +     expected = atof("3.1415"); 
  594. +     printf("%f\n\n", expected);
  595. +     expected = atof("31.415"); 
  596. +     printf("%f\n\n", expected);
  597. +     expected = atof("314.15"); 
  598. +     printf("%f\n\n", expected);
  599. +     expected = atof(".31415"); 
  600. +     printf("%f\n\n", expected);
  601. +     expected = atof(".031415"); 
  602. +     printf("%f\n\n", expected);
  603. +     expected = atof(".0031415"); 
  604. +     printf("%f\n\n", expected);
  605. +     expected = atof(".00031415"); 
  606. +     printf("%f\n\n", expected);
  607. +     expected = atof(".000031415"); 
  608. +     printf("%f\n\n", expected);
  609. +     expected = atof("-3.1415e-9"); 
  610. +     printf("%20.15e\n\n", expected);
  611. +     expected = atof("+3.1415e+009"); 
  612. +     printf("%20.15e\n\n", expected);
  613. + #endif
  614. +     expected = atof("+3.123456789123456789"); 
  615. +     printf("%30.25e\n\n", expected);
  616. +     expected = atof(".000003123456789123456789"); 
  617. +     printf("%30.25e\n\n", expected);
  618. +     expected = atof("3.1234567891234567890000000000"); 
  619. +     printf("%30.25e\n\n", expected);
  620. +     expected = atof("9.22337999999999999999999999999999999999999999"); 
  621. +     printf("%47.45e\n\n", expected);
  622. +     expected = atof("1.0000000000000000000"); 
  623. +     printf("%25.19e\n\n", expected);
  624. +     expected = atof("1.00000000000000000000"); 
  625. +     printf("%26.20e\n\n", expected);
  626. +     expected = atof("1.000000000000000000000"); 
  627. +     printf("%27.21e\n\n", expected);
  628. +     expected = atof("1.000000000000000000000000"); 
  629. +     printf("%30.24e\n\n", expected);
  630. +  
  631. + #if 0
  632. +     expected = atof("1.7e+308");
  633. +     if(errno != 0)
  634. +     {
  635. +     printf("%d\n", errno);
  636. +     }
  637. +     else    printf("1.7e308 OK %g\n", expected);
  638. +     expected = atof("1.797693e308");    /* anything gt looses */
  639. +     if(errno != 0)
  640. +     {
  641. +     printf("%d\n", errno);
  642. +     }
  643. +     else    printf("Max OK %g\n", expected);
  644. +     expected = atof("2.225073858507201E-307");
  645. +     if(errno != 0)
  646. +     {
  647. +     printf("%d\n", errno, expected);
  648. +     }
  649. +     else    printf("Min OK %g\n", expected);
  650. + #endif
  651. +     
  652. +     max_abs_err = 0.0;
  653. +     for(errs = 0, i = 0; i < NTEST; i++)
  654. +     {
  655. +     expected = (double)(s = rand()) / (double)rand();
  656. +     if(s > (RAND_MAX >> 1)) expected = -expected;
  657. +     sprintf(buf, "%.14e", expected);
  658. +     result = atof(buf);
  659. +     e = (expected == 0.0) ? result : (result - expected)/expected;
  660. +     if(e < 0) e = (-e);
  661. +     if(e > 1.0e-6) 
  662. +     {
  663. +         errs++; printf("%.14e %s %.14e (%.14e)\n", expected, buf, result, e);
  664. +     }
  665. +     if (e > max_abs_err) max_abs_err = e;
  666. +     }
  667. +     printf("%ld Error(s), Max abs err %.14e\n", errs, max_abs_err);
  668. + }
  669. + #endif /* TEST */
  670. *** 1.13    1991/12/26 15:53:59
  671. --- close.c    1992/02/04 17:16:05
  672. ***************
  673. *** 9,15 ****
  674.   #include    <device.h>
  675.   #include    <stdlib.h>
  676.   
  677. ! __EXTERN int pipeclose __PROTO((int fd));
  678.   
  679.   #ifdef DEBUG
  680.   #include <stdio.h>
  681. --- 9,15 ----
  682.   #include    <device.h>
  683.   #include    <stdlib.h>
  684.   
  685. ! int (*pipeclose_p) __PROTO((int fd)) = 0;
  686.   
  687.   #ifdef DEBUG
  688.   #include <stdio.h>
  689. ***************
  690. *** 38,44 ****
  691.           rval = close(oldfd);
  692.           }
  693.           else 
  694. !         rval = pipeclose(oldfd);
  695.           return(rval);
  696.       }
  697.       else 
  698. --- 38,44 ----
  699.           rval = close(oldfd);
  700.           }
  701.           else 
  702. !         rval = (*pipeclose_p)(oldfd);
  703.           return(rval);
  704.       }
  705.       else 
  706. *** 1.18    1991/12/26 15:53:59
  707. --- crt0.c    1992/02/04 17:16:05
  708. ***************
  709. *** 240,246 ****
  710.           _stksize = _initial_stack;
  711.       }
  712.       
  713. !     if((_stksize < 0) && (_stksize != -1L))
  714.       {
  715.           _heapbase = (void *) ((long)bp->p_tbase + m);
  716.           _stksize = -_stksize - 1;
  717. --- 240,246 ----
  718.           _stksize = _initial_stack;
  719.       }
  720.       
  721. !     if((_stksize <  -1L))
  722.       {
  723.           _heapbase = (void *) ((long)bp->p_tbase + m);
  724.           _stksize = -_stksize - 1;
  725. ***************
  726. *** 247,253 ****
  727.           }
  728.           
  729.       if((!_initial_stack) && (_stksize >= -1L))
  730. !         {   /* keep all, malloc from Malloc first, then from own heap */
  731.           _split_mem = 1;
  732.           }
  733.   
  734. --- 247,253 ----
  735.           }
  736.           
  737.       if((!_initial_stack) && (_stksize >= -1L))
  738. !         {   /* malloc from Malloc first, then from own heap */
  739.           _split_mem = 1;
  740.           }
  741.   
  742. *** 1.5    1991/03/13 14:58:25
  743. --- ctype.c    1992/02/04 17:16:06
  744. ***************
  745. *** 12,20 ****
  746.           /* some code uses these as function pointers --  i   */
  747.           /* have seen code that does.                 */
  748.   
  749. ! static unsigned char _myctype[UCHAR_MAX+2] =
  750.       {
  751. -        0,                    /* isXXX(EOF) caught here */
  752.       _CTc, _CTc, _CTc, _CTc,                /* 0x00..0x03 */
  753.       _CTc, _CTc, _CTc, _CTc,                /* 0x04..0x07 */
  754.       _CTc, _CTc|_CTs, _CTc|_CTs, _CTc|_CTs,        /* 0x08..0x0B */
  755. --- 12,19 ----
  756.           /* some code uses these as function pointers --  i   */
  757.           /* have seen code that does.                 */
  758.   
  759. ! unsigned char _ctype[UCHAR_MAX+1] =
  760.       {
  761.       _CTc, _CTc, _CTc, _CTc,                /* 0x00..0x03 */
  762.       _CTc, _CTc, _CTc, _CTc,                /* 0x04..0x07 */
  763.       _CTc, _CTc|_CTs, _CTc|_CTs, _CTc|_CTs,        /* 0x08..0x0B */
  764. ***************
  765. *** 64,71 ****
  766.       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xE0..0xEF */
  767.       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0  /* 0xF0..0xFF */
  768.       };
  769. - unsigned char *_ctype = &(_myctype[1]);
  770.   
  771.   int toupper(c)
  772.       int c;
  773. --- 63,68 ----
  774. *** 1.8    1991/05/23 14:43:17
  775. --- doprnt.c    1992/02/04 17:16:07
  776. ***************
  777. *** 18,25 ****
  778. --- 18,34 ----
  779.   /*
  780.    * minorly customized for gcc lib
  781.    *    ++jrb
  782. +  * and for the sfp004 as well as the TT's 68881
  783. +  *      mjr++
  784.    */
  785.   
  786. + static unsigned long
  787. +     __notanumber[2] = { 0x7fffffffL, 0xffffffffL }; /* ieee NAN */
  788. + #define NAN  (*((double *)&__notanumber[0]))
  789. + static unsigned long
  790. +     __p_infinity[2] = { 0x7ff00000L, 0x00000000L }; /* ieee NAN */
  791. + #define INF  (*((double *)&__p_infinity[0]))
  792.   #ifdef LIBC_SCCS
  793.   static char sccsid[] = "@(#)doprnt.c    5.37 (Berkeley) 3/26/89";
  794.   #endif /* LIBC_SCCS */
  795. ***************
  796. *** 30,36 ****
  797.   #include <ctype.h>
  798.   #include <string.h>
  799.   #include <limits.h>
  800. ! #include <math.h>
  801.   
  802.   #ifndef __GNUC__    /* gcc lib has these typedefs in sys/types.h */
  803.   typedef unsigned char u_char;
  804. --- 39,45 ----
  805.   #include <ctype.h>
  806.   #include <string.h>
  807.   #include <limits.h>
  808. ! #include    <math.h>    /* mjr++    */
  809.   
  810.   #ifndef __GNUC__    /* gcc lib has these typedefs in sys/types.h */
  811.   typedef unsigned char u_char;
  812. ***************
  813. *** 39,47 ****
  814.   
  815.   /* 11-bit exponent (VAX G floating point) is 308 decimal digits */
  816.   #define    MAXEXP        308
  817.   /* 128 bit fraction takes up 39 decimal digits; max reasonable precision */
  818. ! #define    MAXFRACT    39
  819.   
  820.   #define    DEFPREC        6
  821.   
  822.   #define    BUF        (MAXEXP+MAXFRACT+1)    /* + decimal point */
  823. --- 48,62 ----
  824.   
  825.   /* 11-bit exponent (VAX G floating point) is 308 decimal digits */
  826.   #define    MAXEXP        308
  827.   /* 128 bit fraction takes up 39 decimal digits; max reasonable precision */
  828. ! # define    MAXFRACT    39
  829. ! # define    MAXEXP        308
  830.   
  831. + #if defined (__M68881__) && !defined (sfp004)
  832. + #  include <math-68881.h>    /* mjr: use the inline functions    */
  833. + #endif    __M68881__
  834.   #define    DEFPREC        6
  835.   
  836.   #define    BUF        (MAXEXP+MAXFRACT+1)    /* + decimal point */
  837. ***************
  838. *** 71,79 ****
  839.   #endif
  840.   
  841.   #ifdef __FLOATS__
  842. ! static char *exponent    __PROTO((char *, int, int));
  843. ! static char *round    __PROTO((double, int *, char *, char *, int, char *));
  844. ! static int  cvt        __PROTO((double, int, int, char *, int, char *, char *));
  845.   #endif
  846.   
  847.   #ifdef __GNUC__
  848. --- 86,101 ----
  849.   #endif
  850.   
  851.   #ifdef __FLOATS__
  852. ! # include    "flonum.h"
  853. ! #  if __STDC__
  854. ! static char *exponent(char *, int, int);
  855. ! static char *round(double, int *, char *, char *, int, char *);
  856. ! static int  cvt(double, int, int, char *, int, char *, char *);
  857. ! #  else
  858. ! static char *exponent();
  859. ! static char *round();
  860. ! static int  cvt();
  861. ! #  endif
  862.   #endif
  863.   
  864.   #ifdef __GNUC__
  865. ***************
  866. *** 97,103 ****
  867.       }                                \
  868.       else                            \
  869.       {                                \
  870. !     extern unsigned long __udivsi3(long, long); /* quot = d0, rem = d1 */     \
  871.       do                             \
  872.       {                            \
  873.           __asm__ volatile("        \
  874. --- 119,125 ----
  875.       }                                \
  876.       else                            \
  877.       {                                \
  878. !         extern unsigned long __udivsi3(); /* quot = d0, rem = d1 */     \
  879.       do                             \
  880.       {                            \
  881.           __asm__ volatile("        \
  882. ***************
  883. *** 127,133 ****
  884.       register int cnt;    /* return value accumulator */
  885.       register int n;        /* random handy integer */
  886.       register char *t;    /* buffer pointer */
  887. !     double _double;        /* double precision arguments %[eEfgG] */
  888.       u_long _ulong;        /* integer arguments %[diouxX] */
  889.       short base;        /* base for [diouxX] conversion */
  890.       short dprec;        /* decimal precision in [diouxX] */
  891. --- 149,158 ----
  892.       register int cnt;    /* return value accumulator */
  893.       register int n;        /* random handy integer */
  894.       register char *t;    /* buffer pointer */
  895. ! #ifdef    __FLOATS__
  896. ! /*    double _double;        *//* double precision arguments %[eEfgG] */
  897. !     union double_di _dd;    /* _double is #defined to be _dd later on */
  898. ! #endif    __FLOATS__
  899.       u_long _ulong;        /* integer arguments %[diouxX] */
  900.       short base;        /* base for [diouxX] conversion */
  901.       short dprec;        /* decimal precision in [diouxX] */
  902. ***************
  903. *** 247,253 ****
  904. --- 272,286 ----
  905.           case 'f':
  906.           case 'g':
  907.           case 'G':
  908. + /* mjr: check for NANs */
  909. + #define    _double _dd.d
  910.               _double = va_arg(argp, double);
  911. +             if( (unsigned long)_dd.i[0] == __notanumber[0])    {
  912. +                 t = strcpy(t, " Not A Number ");
  913. +                 size = strlen(t);
  914. +                 goto pforw;
  915. +             }
  916.               /*
  917.                * don't do unrealistic precision; just pad it with
  918.                * zeroes later, so buffer size stays rational.
  919. ***************
  920. *** 269,274 ****
  921. --- 302,320 ----
  922.               }
  923.               else
  924.                   softsign = 0;
  925. + /* mjr: check for +-INFINITY */
  926. +             if(
  927. +                 ((unsigned long)_dd.i[0] == __p_infinity[0])
  928. + /*              && ((unsigned long)_dd.i[1] == __p_infinity[1]) */
  929. + /* mjr: don't test this in order to catch a conversion bug in gcc-as     */
  930. +             )    {
  931. +             if(softsign == 0)
  932. +                 t = strcpy(t, " Infinity ");
  933. +             else
  934. +                 t = strcpy(t, " -Infinity ");
  935. +                 size = strlen(t);
  936. +                 goto pforw;
  937. +             }
  938.               /*
  939.                * cvt may have to round up past the "start" of the
  940.                * buffer, i.e. ``intf("%.2f", (double)9.999);'';
  941. ***************
  942. *** 321,327 ****
  943.   #ifdef __GNUC__
  944.                   char *p;
  945.                   void *memchr(const void *, int, size_t);
  946.   #else
  947.                   char *p, *memchr();
  948.   #endif
  949. --- 367,372 ----
  950. *** 1.8    1991/12/26 15:53:59
  951. --- fdopen.c    1992/02/04 17:16:08
  952. ***************
  953. *** 3,11 ****
  954.   #include <stdio.h>
  955.   #include <fcntl.h>
  956.   #include <unistd.h>
  957.   
  958. - extern    FILE    _iob[];
  959.   FILE *fdopen(h, mode)
  960.       register int h;
  961.       const register char *mode;
  962. --- 3,10 ----
  963.   #include <stdio.h>
  964.   #include <fcntl.h>
  965.   #include <unistd.h>
  966. + #include <errno.h>
  967.   
  968.   FILE *fdopen(h, mode)
  969.       register int h;
  970.       const register char *mode;
  971. ***************
  972. *** 19,25 ****
  973.           if(!(_iob[i]._flag & (_IORW | _IOREAD | _IOWRT)))
  974.               fp = &_iob[i];    /* empty slot */
  975.       if(!fp)
  976. !         return(NULL);
  977.       while(*mode)
  978.           {
  979.           switch(*mode++)
  980. --- 18,27 ----
  981.           if(!(_iob[i]._flag & (_IORW | _IOREAD | _IOWRT)))
  982.               fp = &_iob[i];    /* empty slot */
  983.       if(!fp)
  984. !       {
  985. !         errno = EMFILE;
  986. !         return(NULL);
  987. !       }
  988.       while(*mode)
  989.           {
  990.           switch(*mode++)
  991. *** 1.15    1991/12/26 15:53:59
  992. --- fopen.c    1992/02/04 17:16:09
  993. ***************
  994. *** 4,9 ****
  995. --- 4,10 ----
  996.   #include <stdlib.h>
  997.   #include <fcntl.h>
  998.   #include <unistd.h>
  999. + #include <errno.h>
  1000.   #ifndef _COMPILER_H
  1001.   #include <compiler.h>
  1002.   #endif
  1003. ***************
  1004. *** 97,103 ****
  1005.           return fp;
  1006.       }
  1007.       else
  1008. !         return NULL;
  1009.       }
  1010.   
  1011.   /*
  1012. --- 98,107 ----
  1013.           return fp;
  1014.       }
  1015.       else
  1016. !       {
  1017. !         errno = EMFILE;
  1018. !         return NULL;
  1019. !       }
  1020.       }
  1021.   
  1022.   /*
  1023. *** 1.10    1991/04/23 16:04:12
  1024. --- fputc.c    1992/02/04 17:16:10
  1025. ***************
  1026. *** 50,54 ****
  1027.           c = '\n';
  1028.           goto _fputc;
  1029.           }
  1030. !     return(c);
  1031.       }
  1032. --- 50,54 ----
  1033.           c = '\n';
  1034.           goto _fputc;
  1035.           }
  1036. !     return(c & 0xff);
  1037.       }
  1038. *** 1.8    1991/06/23 17:07:09
  1039. --- fscanf.c    1992/02/04 17:16:11
  1040. ***************
  1041. *** 5,10 ****
  1042. --- 5,14 ----
  1043.   #include <compiler.h>
  1044.   #endif
  1045.   
  1046. + #ifdef sun
  1047. + # define fungetc ungetc
  1048. + #endif
  1049.   __EXTERN int _scanf __PROTO((FILE *fp, int (*get)(FILE *f),
  1050.                   int (*unget)(int c, FILE *s),
  1051.                   const char *fmt, va_list argp));
  1052. *** 1.8    1991/05/23 14:43:17
  1053. --- getpw.c    1992/02/04 17:16:13
  1054. ***************
  1055. *** 30,35 ****
  1056. --- 30,36 ----
  1057.   */
  1058.   
  1059.   #include <stdio.h>
  1060. + #include <types.h>
  1061.   #include <pwd.h>
  1062.   #include <unistd.h>
  1063.   #include <support.h>
  1064. ***************
  1065. *** 90,97 ****
  1066.           return (& curentry);
  1067.   }
  1068.   
  1069.   struct passwd *getpwuid (uid)
  1070. ! register int uid;
  1071.   {
  1072.       if (! setpwent ())
  1073.           return (NULL);
  1074. --- 91,102 ----
  1075.           return (& curentry);
  1076.   }
  1077.   
  1078. + #if __STDC__
  1079. + struct passwd *getpwuid (uid_t uid)
  1080. + #else
  1081.   struct passwd *getpwuid (uid)
  1082. ! uid_t uid;
  1083. ! #endif
  1084.   {
  1085.       if (! setpwent ())
  1086.           return (NULL);
  1087. ***************
  1088. *** 104,110 ****
  1089.   }
  1090.   
  1091.   struct passwd *getpwnam (name)
  1092. ! register char *name;
  1093.   {
  1094.       if (! setpwent ())
  1095.           return (NULL);
  1096. --- 109,115 ----
  1097.   }
  1098.   
  1099.   struct passwd *getpwnam (name)
  1100. ! register const char *name;
  1101.   {
  1102.       if (! setpwent ())
  1103.           return (NULL);
  1104. *** 1.12    1991/12/26 15:53:59
  1105. --- localtim.c    1992/02/04 17:16:17
  1106. ***************
  1107. *** 152,157 ****
  1108. --- 152,158 ----
  1109.   
  1110.       tzset();
  1111.           offset = *t - _timezone;
  1112. +     if(offset < 0) offset = 0; /* this is questionable */
  1113.           stm = _gmtime(&offset, <im);
  1114.       if (stm == NULL) return stm;        /* check for illegal time */
  1115.           stm->tm_isdst = (dst == -1) ? -1 : 0;
  1116. *** 1.20    1991/12/26 15:53:59
  1117. --- main.c    1992/02/04 17:16:17
  1118. ***************
  1119. *** 116,123 ****
  1120.           _getbuf(f);    /* get a buffer */
  1121.       }
  1122.   
  1123. !     for(i = 0; i <= __OPEN_INDEX(2); i++) {
  1124. !         __open_stat[i].filename = isatty(i) ? 
  1125.               ((_console_dev == 2) ? "/dev/console" : "/dev/tty1")
  1126.                   : (char *)NULL; /* if it was re-dir */
  1127.       }
  1128. --- 116,123 ----
  1129.           _getbuf(f);    /* get a buffer */
  1130.       }
  1131.   
  1132. !     for(i = 0; i <= 2; i++) {
  1133. !         __open_stat[__OPEN_INDEX(i)].filename = isatty(i) ? 
  1134.               ((_console_dev == 2) ? "/dev/console" : "/dev/tty1")
  1135.                   : (char *)NULL; /* if it was re-dir */
  1136.       }
  1137. *** 1.18    1991/12/26 15:53:59
  1138. --- malloc.c    1992/02/04 17:16:18
  1139. ***************
  1140. *** 76,85 ****
  1141.       if (((long)q) == -1)         /* can't alloc any more? */
  1142.           return(NULL);
  1143.   
  1144. !     p->next = q;
  1145.       q->size = sz;
  1146. !     q->next = NULL;
  1147.       q->valid = VAL_FREE;
  1148.       }
  1149.           
  1150.     if (q->size > n + sizeof(struct mem_chunk))
  1151. --- 76,89 ----
  1152.       if (((long)q) == -1)         /* can't alloc any more? */
  1153.           return(NULL);
  1154.   
  1155. !     /* Note: q may be below the highest allocated chunk */
  1156. !     p = &_mchunk_free_list;
  1157. !     while (p->next != NULL && q > p->next)
  1158. !       p = p->next;
  1159.       q->size = sz;
  1160. !     q->next = p->next;
  1161.       q->valid = VAL_FREE;
  1162. +     p->next = q;
  1163.       }
  1164.           
  1165.     if (q->size > n + sizeof(struct mem_chunk))
  1166. ***************
  1167. *** 157,177 ****
  1168.       r->size = 0;
  1169.       r->next = NULL;
  1170.       s = (struct mem_chunk * )(((long) p) + p->size);
  1171. !     if ((!_split_mem) && _heapbase != NULL && s >= (struct mem_chunk *) _heapbase) {
  1172.         assert(s == _heapbase);
  1173.         _heapbase = (char *) p;
  1174.         _stksize += p->size;
  1175. !       o->next = NULL;    /* o is always != NULL here */
  1176.       }
  1177.       }
  1178.       else
  1179.           {
  1180.         s = (struct mem_chunk * )(((long) r) + r->size);
  1181. !       if ((!_split_mem) && _heapbase != NULL && s >= (struct mem_chunk *) _heapbase) {
  1182.           assert(s == _heapbase);
  1183.           _heapbase = (char *) r;
  1184.           _stksize += r->size;
  1185. !         p->next = NULL;
  1186.         } else p->next = r;
  1187.       }
  1188.   }
  1189. --- 161,185 ----
  1190.       r->size = 0;
  1191.       r->next = NULL;
  1192.       s = (struct mem_chunk * )(((long) p) + p->size);
  1193. !     if ((!_split_mem) && _heapbase != NULL &&
  1194. !         s >= (struct mem_chunk *) _heapbase &&
  1195. !         s < (struct mem_chunk *) (_heapbase + _stksize)) {
  1196.         assert(s == _heapbase);
  1197.         _heapbase = (char *) p;
  1198.         _stksize += p->size;
  1199. !       o->next = p->next;    /* o is always != NULL here */
  1200.       }
  1201.       }
  1202.       else
  1203.           {
  1204.         s = (struct mem_chunk * )(((long) r) + r->size);
  1205. !       if ((!_split_mem) && _heapbase != NULL &&
  1206. !           s >= (struct mem_chunk *) _heapbase &&
  1207. !           s < (struct mem_chunk *) (_heapbase + _stksize)) {
  1208.           assert(s == _heapbase);
  1209.           _heapbase = (char *) r;
  1210.           _stksize += r->size;
  1211. !         p->next = r->next;
  1212.         } else p->next = r;
  1213.       }
  1214.   }
  1215. *** 1.14    1992/01/14 18:46:50
  1216. --- mincl    1992/02/04 17:16:19
  1217. ***************
  1218. *** 79,93 ****
  1219.       $(CC) $(CFFLAGS) -c fork.c
  1220.   
  1221.   #
  1222. ! # setjmp, div, _normdf, ldexp, frexp must be pre-processed
  1223.   %.s : %.cpp
  1224.       $(CPP) $(PPFLAGS) $< $@
  1225.   
  1226.   setjmp.o : setjmp.cpp
  1227.   div.o : div.cpp
  1228. ! _normdf.o : _normdf.cpp
  1229. ! ldexp.o : ldexp.cpp
  1230. ! frexp.o : frexp.cpp
  1231.   
  1232.   #
  1233.   # integer only io stuff
  1234. --- 79,107 ----
  1235.       $(CC) $(CFFLAGS) -c fork.c
  1236.   
  1237.   #
  1238. ! # Assembler stuff that needs to be preprocessed by cpp into a .S
  1239. ! #
  1240.   %.s : %.cpp
  1241.       $(CPP) $(PPFLAGS) $< $@
  1242.   
  1243.   setjmp.o : setjmp.cpp
  1244.   div.o : div.cpp
  1245. ! _addsubd.o: _addsubd.cpp
  1246. ! _addsubs.o: _addsubs.cpp
  1247. ! _divdf3.o: _divdf3.cpp
  1248. ! _divsf3.o: _divsf3.cpp
  1249. ! _extends.o: _extends.cpp
  1250. ! _fixdfsi.o: _fixdfsi.cpp
  1251. ! _floatsi.o: _floatsi.cpp
  1252. ! _fxunsd.o: _fxunsd.cpp
  1253. ! _muldf3.o: _muldf3.cpp
  1254. ! _mulsf3.o: _mulsf3.cpp
  1255. ! _normdf.o: _normdf.cpp
  1256. ! _normsf.o: _normsf.cpp
  1257. ! _truncdf.o: _truncdf.cpp
  1258. ! frexp.o: frexp.cpp
  1259. ! ldexp.o: ldexp.cpp
  1260. ! modf.o: modf.cpp
  1261.   
  1262.   #
  1263.   # integer only io stuff
  1264. ***************
  1265. *** 103,109 ****
  1266.   
  1267.   # other dependencies
  1268.   bcopy.o : bcopy.s
  1269. - modf.o  : modf.s
  1270.   atof.o  : flonum.h
  1271.   
  1272.   #
  1273. --- 117,122 ----
  1274. ***************
  1275. *** 129,135 ****
  1276.       rm -f $(ANSI)
  1277.       rm -f $(PORT)
  1278.       rm -f $(IIOBJ)
  1279. !     rm -f setjmp.s div.s _normdf.s ldexp.s frexp.s
  1280.   
  1281.   realclean: clean
  1282.       rm -f $(ALL) $(ALL020)
  1283. --- 142,151 ----
  1284.       rm -f $(ANSI)
  1285.       rm -f $(PORT)
  1286.       rm -f $(IIOBJ)
  1287. !     rm -f setjmp.s div.s
  1288. !     rm -f _addsubd.s _addsubs.s _divdf3.s _divsf3.s _extends.s _fixdfsi.s
  1289. !     rm -f _floatsi.s _fxunsd.s _muldf3.s _mulsf3.s _normdf.s _normsf.s
  1290. !     rm -f _truncdf.s frexp.s ldexp.s modf.s
  1291.   
  1292.   realclean: clean
  1293.       rm -f $(ALL) $(ALL020)
  1294. *** 1.2    1991/12/26 15:53:59
  1295. --- pipe.c    1992/02/04 17:16:22
  1296. ***************
  1297. *** 2,14 ****
  1298.   #include <stat.h>
  1299.   #include <types.h>
  1300.   #include <errno.h>
  1301. - #include <stdio.h>
  1302.   #include <stdlib.h>
  1303.   #define __MINT__
  1304.   #include <mintbind.h>
  1305.   
  1306.   extern int __mint;
  1307.   
  1308.   /**
  1309.    ** (sjk)++ These routines simulate a eunchs pipe() call using temporary 
  1310.    **         files. A linked list of type *_pipe is kept as to allow as 
  1311. --- 2,25 ----
  1312.   #include <stat.h>
  1313.   #include <types.h>
  1314.   #include <errno.h>
  1315.   #include <stdlib.h>
  1316. + #include <unistd.h>
  1317. + #include <string.h>
  1318.   #define __MINT__
  1319.   #include <mintbind.h>
  1320.   
  1321.   extern int __mint;
  1322.   
  1323. + #if defined(DEBUG)
  1324. + #  include <stdio.h>
  1325. + #endif
  1326. + #ifndef _COMPILER_H
  1327. + #  include <compiler.h>
  1328. + #endif
  1329. + __EXTERN char *tmpnam __PROTO((char *buf));
  1330.   /**
  1331.    ** (sjk)++ These routines simulate a eunchs pipe() call using temporary 
  1332.    **         files. A linked list of type *_pipe is kept as to allow as 
  1333. ***************
  1334. *** 29,34 ****
  1335. --- 40,48 ----
  1336.   static struct _pipe *__pipes = NULL;
  1337.   static int del_list (struct _pipe *);
  1338.   
  1339. + __EXTERN int pipeclose __PROTO((int fd));
  1340. + extern int (*pipeclose_p) __PROTO((int fd));
  1341.   /*---------------------------------------------------------------------------*/
  1342.   /* Make a pipe, open the tempory file, set it up for writing, add the pipe   */
  1343.   /* descriptor to our linked list of pipes, and return.                       */
  1344. ***************
  1345. *** 35,45 ****
  1346.   /*---------------------------------------------------------------------------*/
  1347.   int pipe(fildes)
  1348.   int fildes[2];
  1349. ! { int       fd,ifd; 
  1350.     char name[40];
  1351.     struct _pipe *p;
  1352.   
  1353. !   tmpnam(name);                              /* Make a temporary file name. /*
  1354.     
  1355.     /*----------------------------------------------*/
  1356.     /* Open the pipe for reading and writing.       */
  1357. --- 49,59 ----
  1358.   /*---------------------------------------------------------------------------*/
  1359.   int pipe(fildes)
  1360.   int fildes[2];
  1361. ! { int       fd; 
  1362.     char name[40];
  1363.     struct _pipe *p;
  1364.   
  1365. !   tmpnam(name);                              /* Make a temporary file name. */
  1366.     
  1367.     /*----------------------------------------------*/
  1368.     /* Open the pipe for reading and writing.       */
  1369. ***************
  1370. *** 51,57 ****
  1371. --- 65,75 ----
  1372.   #endif
  1373.   
  1374.     if (fd < 0)
  1375. + #if defined(DEBUG)
  1376.       fprintf(stderr,"fd returns : %d! PIPE(%s) failed.\n",fd, name);
  1377. + #else
  1378. +     /* nothing */;
  1379. + #endif
  1380.     else 
  1381.       { /*------------------------------------------*/
  1382.         /* Get a pipe description block and         */
  1383. ***************
  1384. *** 64,69 ****
  1385. --- 82,89 ----
  1386.         strcpy(p->p_name,name);           /* fill in name.                   */  
  1387.         p->flag = 'w';                    /* initially for write.            */
  1388.         p->file_des = fd;                 /* fill in the pipe descriptor.    */
  1389. +       if(!__pipes)
  1390. +     pipeclose_p = pipeclose;    /* patch in addr of close routine  */
  1391.         /*-------------------------------------------------------------------*/
  1392.         p->next = __pipes;                /* Link to our list of open pipes. */
  1393.         __pipes     = p;
  1394. ***************
  1395. *** 70,76 ****
  1396.         /*-------------------------------------------------------------------*/ 
  1397.         fildes[0] = fildes[1] = fd;       /* we fill in fildes[].            */
  1398.         if (__mint)
  1399. !     Fcntl(fd,0L,2);                 /* Make fd shared across Pexecs()  */
  1400.       }
  1401.     return(fd);                           /* Return the file descriptor.     */
  1402.   }
  1403. --- 90,96 ----
  1404.         /*-------------------------------------------------------------------*/ 
  1405.         fildes[0] = fildes[1] = fd;       /* we fill in fildes[].            */
  1406.         if (__mint)
  1407. !     (void) Fcntl(fd,0L,2);          /* Make fd shared across Pexecs()  */
  1408.       }
  1409.     return(fd);                           /* Return the file descriptor.     */
  1410.   }
  1411. ***************
  1412. *** 84,90 ****
  1413.   int
  1414.   pipeclose(fd)
  1415.   int fd;
  1416. ! {  struct _pipe *p,*q = NULL;
  1417.      int    ifd;
  1418.      for (p=__pipes; p; p=p->next)
  1419.       { if (fd == p->file_des) 
  1420. --- 104,110 ----
  1421.   int
  1422.   pipeclose(fd)
  1423.   int fd;
  1424. ! {  struct _pipe *p;
  1425.      int    ifd;
  1426.      for (p=__pipes; p; p=p->next)
  1427.       { if (fd == p->file_des) 
  1428. ***************
  1429. *** 109,115 ****
  1430. --- 129,137 ----
  1431.             }
  1432.         }
  1433.       }
  1434. + #if defined(DEBUG)
  1435.      fprintf(stderr,"attempt to close nonexistant pipe.\n");
  1436. + #endif
  1437.      return(-1);
  1438.   }
  1439.   
  1440. ***************
  1441. *** 136,141 ****
  1442. --- 158,165 ----
  1443.             q = r;                        /* update trailing pointer.    */
  1444.       }
  1445.       }
  1446. + #if defined(DEBUG)
  1447.     fprintf(stderr,"Attempt to delete a nonexisting pipe form list (__pipes).");
  1448. + #endif
  1449.     return(-1);
  1450.   }
  1451. *** 1.8    1991/12/26 15:53:59
  1452. --- sbrk.c    1992/02/04 17:16:24
  1453. ***************
  1454. *** 9,14 ****
  1455. --- 9,20 ----
  1456.      unlike Unix.
  1457.   */
  1458.   
  1459. + /* Further WARNING: in a split_mem model the memory addresses will NOT
  1460. +    be monotonous. sigh!  (i hate these mem models as much as the next
  1461. +    person. as usual, people at atari are totally oblivious to such
  1462. +    brain damage, even when pointed out to them. sigh!)
  1463. + */
  1464.   #include <osbind.h>
  1465.   #include <unistd.h>
  1466.   #include <errno.h>
  1467. *** 1.12    1991/12/26 15:53:59
  1468. --- scanf.c    1992/02/04 17:16:25
  1469. ***************
  1470. *** 67,73 ****
  1471.   #define    inchar()    ((c = ((*get)(s))) == EOF ? EOF : (++read_in, c))
  1472.   #define unchar(c)    (--read_in, (*unget)(c, s))
  1473.   #define    conv_error()    return((c == EOF || ((*unget)(c, s))), done)
  1474. ! #define input_error()    return(-1)
  1475.   #define    memory_error()    return((errno = ENOMEM), EOF)
  1476.   
  1477.   
  1478. --- 67,73 ----
  1479.   #define    inchar()    ((c = ((*get)(s))) == EOF ? EOF : (++read_in, c))
  1480.   #define unchar(c)    (--read_in, (*unget)(c, s))
  1481.   #define    conv_error()    return((c == EOF || ((*unget)(c, s))), done)
  1482. ! #define input_error()    return( done < 1 ? EOF : done )
  1483.   #define    memory_error()    return((errno = ENOMEM), EOF)
  1484.   
  1485.   
  1486. ***************
  1487. *** 250,263 ****
  1488.           
  1489.           if (width == -1)
  1490.           width = 1;
  1491. !         
  1492. !         if (do_assign)
  1493. !         while (inchar() != EOF && width-- > 0)
  1494.               *str++ = c;
  1495. !         else
  1496. !         while (inchar() != EOF && width-- > 0)
  1497.               ;
  1498. !         
  1499.           if (do_assign)
  1500.           ++done;
  1501.           
  1502. --- 250,264 ----
  1503.           
  1504.           if (width == -1)
  1505.           width = 1;
  1506. ! /* mjr:    */        
  1507. !         if (do_assign) {
  1508. !         do
  1509.               *str++ = c;
  1510. !         while (inchar() != EOF && --width > 0);
  1511. !         } else
  1512. !         while (inchar() != EOF && --width > 0)
  1513.               ;
  1514.           if (do_assign)
  1515.           ++done;
  1516.           
  1517. *** 1.16    1991/12/26 15:53:59
  1518. --- stat.c    1992/02/04 17:16:28
  1519. ***************
  1520. *** 105,112 ****
  1521.       return d;
  1522.   }
  1523.   
  1524. ! int
  1525. ! stat(_path, st)
  1526.       const char    *_path;
  1527.       struct stat    *st;
  1528.   {
  1529. --- 105,112 ----
  1530.       return d;
  1531.   }
  1532.   
  1533. ! static int
  1534. ! _stat(_path, st)
  1535.       const char    *_path;
  1536.       struct stat    *st;
  1537.   {
  1538. ***************
  1539. *** 232,238 ****
  1540.       st->st_uid = geteuid();    /* the current user owns every file */
  1541.       st->st_gid = getegid();
  1542.       st->st_blksize = 1024;
  1543. !     return 0;
  1544.   }
  1545.   
  1546.   #include <fcntl.h>
  1547. --- 232,246 ----
  1548.       st->st_uid = geteuid();    /* the current user owns every file */
  1549.       st->st_gid = getegid();
  1550.       st->st_blksize = 1024;
  1551. !     return nval;
  1552. ! }
  1553. ! int
  1554. ! stat(path, st)
  1555. !     const char    *path;
  1556. !     struct stat    *st;
  1557. ! {
  1558. !     return _stat(path, st) < 0 ? -1 : 0;
  1559.   }
  1560.   
  1561.   #include <fcntl.h>
  1562. ***************
  1563. *** 336,367 ****
  1564.       const char *_path;
  1565.       struct stat *st;
  1566.   {
  1567. !     char path[FILENAME_MAX];
  1568. !     int n, r, linksiz;
  1569. !     SYMDIR *dir;
  1570. !     SYMENTRY *ent;
  1571.   
  1572.   /* unx2dos returns _NM_LINK if the last path component was a symbolic link
  1573.    * in this case, __link_name and __link_path are set to the name and path
  1574. !  * of the symbolic link file, and __link_to to its contents
  1575.    */
  1576. !     n = unx2dos(_path, path);
  1577. !     linksiz = strlen(__link_to);
  1578.   
  1579. !     if (n == _NM_LINK && _lAUTO && (dir = _read_symdir(__link_path))) {
  1580. !         ent = _symdir_lookup(dir, __link_name);
  1581. !         assert(ent != 0);
  1582. !         if (ent->flags & SD_AUTO)
  1583. !             n = _NM_OK;    /* pretend that it wasn't a link*/
  1584. !         _free_symdir(dir);
  1585. !     }
  1586. !     r = stat(_path, st);
  1587. !     if (n != _NM_LINK || r < 0)        /* not a symlink */
  1588.           return r;
  1589. !     st->st_size = linksiz;
  1590. !     st->st_blocks = (st->st_size + 1023)/1024;
  1591. !     st->st_mode = ((st->st_mode & ~S_IFMT) | S_IFLNK);
  1592.       return 0;
  1593.   }
  1594. --- 344,366 ----
  1595.       const char *_path;
  1596.       struct stat *st;
  1597.   {
  1598. !     int r;
  1599.   
  1600.   /* unx2dos returns _NM_LINK if the last path component was a symbolic link
  1601.    * in this case, __link_name and __link_path are set to the name and path
  1602. !  * of the symbolic link file, __link_to to its contents, and __link_flags
  1603. !  * its flags.
  1604.    */
  1605. !     r = _stat(_path, st);
  1606.   
  1607. !     if (r < 0)
  1608.           return r;
  1609. !     if (r == _NM_LINK && !(__link_flags & SD_AUTO))
  1610. !     {
  1611. !         st->st_size = strlen(__link_to);
  1612. !         st->st_blocks = 1;
  1613. !         st->st_mode = ((st->st_mode & ~S_IFMT) | S_IFLNK);
  1614. !     }
  1615.       return 0;
  1616.   }
  1617. *** 1.12    1991/06/11 23:04:27
  1618. --- system.c    1992/02/04 17:16:33
  1619. ***************
  1620. *** 6,11 ****
  1621. --- 6,15 ----
  1622.    * Modified by Allan Pratt to call unx2dos on redirect file names
  1623.    * and to call spawnvp() without calling fork() -- why bother?
  1624.    *
  1625. +  * Modified by Frank Ridderbusch in _parseargs() to handle the case
  1626. +  * >'file'. Without the modification, the quotes would end up in the
  1627. +  * filename for redirection
  1628. +  *
  1629.    */
  1630.   
  1631.   #include <stdio.h>
  1632. ***************
  1633. *** 78,84 ****
  1634.       const char *s;
  1635.   {
  1636.       Argentry *cur, *res;
  1637. !     char buf[FILENAME_MAX];
  1638.       char *t, quote;
  1639.   
  1640.       res = cur = _argalloc("");
  1641. --- 82,88 ----
  1642.       const char *s;
  1643.   {
  1644.       Argentry *cur, *res;
  1645. !     char buf[BUFSIZ];
  1646.       char *t, quote;
  1647.   
  1648.       res = cur = _argalloc("");
  1649. ***************
  1650. *** 95,102 ****
  1651.               if (*s) s++;    /* skip final quote */
  1652.           }
  1653.           else {
  1654. !             while (*s && !isspace(*s))
  1655.                   *t++ = *s++;
  1656.               if (*s && ( *(s-1) == '>' || *(s-1) == '<' ))
  1657.                   goto again;
  1658.           }
  1659. --- 99,109 ----
  1660.               if (*s) s++;    /* skip final quote */
  1661.           }
  1662.           else {
  1663. !             while (*s && !isspace(*s)) {
  1664.                   *t++ = *s++;
  1665. +                 if (isquote(*s))
  1666. +                     goto again;
  1667. +             }
  1668.               if (*s && ( *(s-1) == '>' || *(s-1) == '<' ))
  1669.                   goto again;
  1670.           }
  1671. *** 1.20    1991/12/26 15:53:59
  1672. --- unx2dos.c    1992/02/04 17:16:37
  1673. ***************
  1674. *** 305,311 ****
  1675.   #define MAXRECURSE 12
  1676.   
  1677.   char __link_path[FILENAME_MAX], __link_name[_LIB_NAME_MAX],
  1678. !     __link_to[_LIB_NAME_MAX];
  1679.   int __link_flags = 0;
  1680.   
  1681.   static int
  1682. --- 305,311 ----
  1683.   #define MAXRECURSE 12
  1684.   
  1685.   char __link_path[FILENAME_MAX], __link_name[_LIB_NAME_MAX],
  1686. !     __link_to[FILENAME_MAX];
  1687.   int __link_flags = 0;
  1688.   
  1689.   static int
  1690. ***************
  1691. *** 392,400 ****
  1692.       while (ent) {
  1693.           if (!strcmp(ent->linkname, name)) {
  1694.           change = _NM_LINK;
  1695. -         /* only set __link_to once */
  1696. -         if (!__link_to[0])
  1697. -             strcpy(__link_to, ent->linkto);
  1698.   #ifdef DEBUG
  1699.           printf("...following link (%s)->(%s)\n", name, ent->linkto);
  1700.   #endif
  1701. --- 392,397 ----
  1702. ***************
  1703. *** 401,406 ****
  1704. --- 398,404 ----
  1705.           
  1706.           if (level == 0) {
  1707.               strcpy(__link_path, result);
  1708. +             strcpy(__link_to, ent->linkto);
  1709.               __link_flags = ent->flags;
  1710.           }
  1711.           /*
  1712. ***************
  1713. *** 503,510 ****
  1714.           unx = (unx[6]) ? &unx[7] : &unx[6];
  1715.       }
  1716.       }
  1717. -     
  1718. -     __link_to[0]='\0';
  1719.       
  1720.       change = _canon(path, (char *)unx, dos, 0);
  1721.       /*
  1722. --- 501,506 ----
  1723. *** 1.15    1991/07/23 22:06:28
  1724. --- write.c    1992/02/04 17:16:37
  1725. ***************
  1726. *** 103,109 ****
  1727.           if (*s == '\r')
  1728.               __col_pos = 0;
  1729.               else
  1730. !         if (*s >= ' ' && *s < 0177)
  1731.               __col_pos++;
  1732.               else
  1733.           if (*s == '\t')
  1734. --- 103,109 ----
  1735.           if (*s == '\r')
  1736.               __col_pos = 0;
  1737.               else
  1738. !         if (*(unsigned char *)s >= ' ')
  1739.               __col_pos++;
  1740.               else
  1741.           if (*s == '\t')
  1742.